package com.hyacinth.core.sysmgr.domain;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.*;

import com.hyacinth.common.framework.Domain;

@Entity
@Table(name = "sys_menu")
public class SysMenu extends Domain {

    /**
     *
     */
    private static final long serialVersionUID = 7397096661970938646L;

    private String name;

    private String tree;

    private String icon;

    private String url;

    private Integer sort;

    private Long pid;

    private List<SysMenu> children = new ArrayList<SysMenu>();

    private List<SysOperation> operations = new ArrayList<SysOperation>();

    @Column(name = "name")
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Column(name = "tree")
    public String getTree() {
        return tree;
    }

    public void setTree(String tree) {
        this.tree = tree;
    }

    @Column(name = "icon", nullable = true)
    public String getIcon() {
        return icon;
    }

    public void setIcon(String icon) {
        this.icon = icon;
    }

    @Column(name = "url")
    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    /*
    @ManyToOne(cascade=CascadeType.MERGE,fetch=FetchType.EAGER)
    @JoinColumn(name="pid")
    public Menu getParent() {
        return parent;
    }

    public void setParent(Menu parent) {
        this.parent = parent;
    }


    @OneToMany(mappedBy="parent", cascade=CascadeType.REMOVE, fetch=FetchType.LAZY)
    @OrderBy(value="sort ASC")
    */
    @Transient
    public List<SysMenu> getChildren() {
        return children;
    }

    public void setChildren(List<SysMenu> children) {
        this.children = children;
    }

    @Column(name = "sort", nullable = true)
    public Integer getSort() {
        return sort;
    }

    public void setSort(Integer sort) {
        this.sort = sort;
    }

    @Column(name = "pid", nullable = true)
    public Long getPid() {
        return pid;
    }

    public void setPid(Long pid) {
        this.pid = pid;
    }

    @OneToMany(mappedBy = "menu",fetch = FetchType.EAGER)
    public List<SysOperation> getOperations() {
        return operations;
    }

    public void setOperations(List<SysOperation> operations) {
        this.operations = operations;
    }
}
